<template>
    <view>
        <view class="list" v-for="(item, i) in list" :key="i">
            <view>
                <view>{{ i+1 }}</view>
                <view>{{ item.username }}</view>
                <view>{{ item.mobile }}</view>
                <view>{{ item.email }}</view>
            </view>
        </view>
        <view class="btn">
            <button @click="remove(item._id)"></button>
            <button @click="gotoDetail(item._id)"></button>
        </view>
    </view>
</template>
<script>
export default{
    data(){
        return{
            list:[]
        }
    },
    onLoad(){
        this.getData();
    },
    methods:{
        getData(){
            uniCloud.callFunction({
                name:'getUser',
                success:(e)=>{
                    this.list = e.result.data;
                }
        })
        },
        remove(_id){
            uniCloud.callFunction({
                name:'removeUser',
                data:{'id':_id},
                success:(e)=>{
                    uni.showToast({
                        title:'...',
                        duration:2000
                    })
                    this.getData();
                }
            })
        }
}
</script>